import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

public class Test {

    public static void main(String[] args) {
        HashBuck hashBuck = new HashBuck();
        hashBuck.push(3,2345);
        hashBuck.push(5,324);
        hashBuck.push(6,324);
        hashBuck.push(7,324);
        hashBuck.push(8,324);
        hashBuck.push(9,324);
        hashBuck.push(1,324);
        hashBuck.push(2,324);
    }
    public static void main1(String[] args) {
        Map<String,Integer> map = new TreeMap<>();//搜索树
        //设置的是什么类型,最后输出也用什么类型,否则找不到就会直接报错
        map.put("abc",4);
        map.put("hello",5);
        map.put("world",6);

        Integer val = map.get("abc");
        Integer val2 = map.get("adc");
        System.out.println(val);
        System.out.println(val2);

        //找不到返回后面的默认值
        Integer val3  =map.getOrDefault("asc",45);
        System.out.println(val3);

        //set不能存储相同的元素
        Set<String> set = map.keySet();
        System.out.println("set" + set );//单独获取

        //一起获取
        Set<Map.Entry<String,Integer>> set2 = map.entrySet();
        for (Map.Entry<String,Integer> entry:set2
             ) {
            System.out.println("key:" + entry.getKey()+" "+ "val:"+entry.getValue());
        }
    }
}
